package com.lagou.rpc.provider.service;

import com.lagou.rpc.api.IScoreService;
import com.lagou.rpc.pojo.Score;
import com.lagou.rpc.pojo.User;
import com.lagou.rpc.provider.anno.RpcService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author 梅松
 * @Date 2021/9/5 16:10
 */
@RpcService
@Service
public class ScoreServiceImpl implements IScoreService {

    Map<Object, Score> scoreMap = new HashMap();


    /**
     * 根据id查询成绩
     * @param id
     * @return
     */
    @Override
    public Score getById(int id) {
        if(scoreMap.size() == 0){
            Score score1= new Score();
            score1.setId(1);
            score1.setScore(60);
            scoreMap.put(score1.getId(),score1);
            Score score2= new Score();
            score2.setId(2);
            score2.setScore(100);
            scoreMap.put(score2.getId(),score2);
        }
        return scoreMap.get(id);
    }
}
